WordPress

推荐列表 站点导航

当前位置:首页 > 建站教程 > WordPress >

WordPress无插件调用最新、热门、随机文章实例代码

来源:网络整理  作者:  发布时间:2020-12-18 10:56
WordPress无插件调用最新、热门、随机文章,具体实现代码如下,感兴趣的朋友可以参考下哈,希望对大家在新闻调用...
$query_posts = new WP_Query();
‘orderby’ => ‘comment_count’, // 依评论数排序.
<ul>
$postid = $post->ID;

WordPress无插件调用最新、热门、随机文章,具体实现代码如下,感兴趣的朋友可以参考下哈,希望对大家在新闻调用上有所帮助

<?php
);
‘post_status’ => ‘publish’, // 只选公开的文章.
$args = array(
</ul>
 
‘post__not_in’ => array($post->ID),//排除当前文章
?>
<?php while ($query_posts->have_posts()) : $query_posts->the_post(); ?>
<?php $post_query = new WP_Query(‘showposts=10′);
<?php
$query_posts->query($args);
<?php endwhile;?>

如您对本文有所疑义或者有任何需求,欢迎咨询本网站!

<ul>
<ul>

WordPress无插件调用最新、热门、随机文章实例代码 (https://www.wpmee.com/) WordPress教程 第1张

$query_posts = new WP_Query();
$do_not_duplicate = $post->ID; ?>
$args = array( ‘orderby’ => ‘rand’, ‘post__not_in’ => array($post->ID), ‘showposts’ => 10);
<li><a href=https://www.wpmee.com/”<?php the_permalink(); ?>” title=https://www.wpmee.com/”<?php the_title(); ?>”><?php the_title(); ?></a></li>

调用热门文章:

<li><a href=https://www.wpmee.com/”<?php the_permalink(); ?>”><?php the_title(); ?></a></li>
‘caller_get_posts’ => 1, // 排除置顶文章.
‘posts_per_page’ => $post_num
</ul>
 

调用随机文章:

while( $query_posts->have_posts() ) { $query_posts->the_post(); ?>

调用最新文章:

while ($post_query->have_posts()) : $post_query->the_post();
$query_posts->query($args);
$post_num = 10; // 设置调用条数
</ul>
 
‘post_password’ => ”,
<?php endwhile; ?>
<li><a href=https://www.wpmee.com/”<?php the_permalink(); ?>” rel=”bookmark” title=https://www.wpmee.com/”<?php the_title_attribute(); ?>”><?php the_title(); ?></a></li>
<?php } wp_reset_query();?>
global $post;

相关热词: 调用 实例

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!

本文地址: https://v30.fanwenzhu.com/jz/wp/5153.shtml

Copyright © www.juheyunku.com      关于 | 合作 | 声明 | 联系 | 更新 | 地图 | Tags

WordPress无插件调用最新、热门、随机文章实例代码

2020-12-18 编辑:

$query_posts = new WP_Query();
‘orderby’ => ‘comment_count’, // 依评论数排序.
<ul>
$postid = $post->ID;

WordPress无插件调用最新、热门、随机文章,具体实现代码如下,感兴趣的朋友可以参考下哈,希望对大家在新闻调用上有所帮助

<?php
);
‘post_status’ => ‘publish’, // 只选公开的文章.
$args = array(
</ul>  
‘post__not_in’ => array($post->ID),//排除当前文章
?>
<?php while ($query_posts->have_posts()) : $query_posts->the_post(); ?>
<?php $post_query = new WP_Query(‘showposts=10′);
<?php
$query_posts->query($args);
<?php endwhile;?>

如您对本文有所疑义或者有任何需求,欢迎咨询本网站!

<ul>
<ul>

WordPress无插件调用最新、热门、随机文章实例代码 (https://www.wpmee.com/) WordPress教程 第1张

$query_posts = new WP_Query();
$do_not_duplicate = $post->ID; ?>
$args = array( ‘orderby’ => ‘rand’, ‘post__not_in’ => array($post->ID), ‘showposts’ => 10);
<li><a href=https://www.wpmee.com/”<?php the_permalink(); ?>” title=https://www.wpmee.com/”<?php the_title(); ?>”><?php the_title(); ?></a></li>

调用热门文章:

<li><a href=https://www.wpmee.com/”<?php the_permalink(); ?>”><?php the_title(); ?></a></li>
‘caller_get_posts’ => 1, // 排除置顶文章.
‘posts_per_page’ => $post_num
</ul>
 

调用随机文章:

while( $query_posts->have_posts() ) { $query_posts->the_post(); ?>

调用最新文章:

while ($post_query->have_posts()) : $post_query->the_post();
$query_posts->query($args);
$post_num = 10; // 设置调用条数
</ul>
 
‘post_password’ => ”,
<?php endwhile; ?>
<li><a href=https://www.wpmee.com/”<?php the_permalink(); ?>” rel=”bookmark” title=https://www.wpmee.com/”<?php the_title_attribute(); ?>”><?php the_title(); ?></a></li>
<?php } wp_reset_query();?>
global $post;

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供学习参考!
本文地址为 https://v30.fanwenzhu.com/jz/wp/5153.shtml

相关文章

风云图片

推荐阅读

返回WordPress频道首页